<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class DefaultController extends AppController {

    var $layout = 'default';
    var $uses = array(
        'Mgame'
    );

    function index() {
        $this->set('title_for_layout', 'Game điện thoại | Game dien thoai | game 18+');

        $page = array_key_exists('page', $this->params['named']) ? $this->params['named']['page'] : 1;
        $conditions = array(
            'Mgame.published' => 1
        );
        $this->paginate = array(
            'fields' => array('Mgame.hot_icon, Mgame.url_download,Mgame.short_description,Mgame.show_description,Mgame.id, Mgame.alias, Mgame.title, Mgame.thumbnail, Mgame.description'),
            'conditions' => $conditions,
            'limit' => 10,
            'order' => array(
                'Mgame.id' => 'DESC'
            ),
        );
        $data = $this->paginate('Mgame');
        shuffle($data);
        $this->set('total', $this->params['paging']['Mgame']['count']);
        $this->set('data', $data);
        $this->set('thumbnail_thumb_url_path', Configure::read('mgame_thumbnail_url_path'));
        $this->set('start_page', $page);
        $this->set('home_css', ' class="active"');
    }
    function hotest() {
        $this->set('title_for_layout', 'Game mobile hay nhất | Game điện thoại | game java');

        $page = array_key_exists('page', $this->params['named']) ? $this->params['named']['page'] : 1;
        $conditions = array(
            'Mgame.published' => 1,
            'Mgame.hot_game'    => 1
        );
        $this->paginate = array(
            'fields' => array('Mgame.hot_icon, Mgame.url_download,Mgame.short_description,Mgame.show_description,Mgame.id, Mgame.alias, Mgame.title, Mgame.thumbnail, Mgame.description'),
            'conditions' => $conditions,
            'limit' => 10,
            'order' => array(
                'Mgame.id' => 'DESC'
            ),
        );
        $data = $this->paginate('Mgame');
        shuffle($data);
        $this->set('total', $this->params['paging']['Mgame']['count']);
        $this->set('data', $data);
        $this->set('thumbnail_thumb_url_path', Configure::read('mgame_thumbnail_url_path'));
        $this->set('start_page', $page);
        $this->set('hotest_css', ' class="active"');
    }
    function popular() {
        $this->set('title_for_layout', 'Game mobile nhiều người chơi nhất | Game điện thoại');

        $page = array_key_exists('page', $this->params['named']) ? $this->params['named']['page'] : 1;
        $conditions = array(
            'Mgame.published' => 1,
            'Mgame.popular'    => 1
        );
        $this->paginate = array(
            'fields' => array('Mgame.hot_icon, Mgame.url_download,Mgame.short_description,Mgame.show_description,Mgame.id, Mgame.alias, Mgame.title, Mgame.thumbnail, Mgame.description'),
            'conditions' => $conditions,
            'limit' => 10,
            'order' => array(
                'Mgame.id' => 'DESC'
            ),
        );
        $data = $this->paginate('Mgame');
        shuffle($data);
        $this->set('total', $this->params['paging']['Mgame']['count']);
        $this->set('data', $data);
        $this->set('thumbnail_thumb_url_path', Configure::read('mgame_thumbnail_url_path'));
        $this->set('start_page', $page);
        $this->set('popular_css', ' class="active"');
    }
    function detail($id, $slug){
        $fields = array(
            '*'
        );
        $content = $this->Mgame->read($fields, $id);
        $this->set('title_for_layout', "Chơi game - {$content['Mgame']['title']}");
        $this->set('content', $content);
    }
}

?>
